package com.UI
{
	import com.*;
	import com.Engine.*;
	import com.Packet.*;
	
	import flash.display.*;
	import flash.events.*;
	import flash.external.*;
	import flash.filters.*;
	import flash.geom.*;
	import flash.system.*;
	import flash.text.*;
	import flash.ui.*;
	import flash.utils.*;
	
	import org.aswing.*;
	import org.aswing.border.*;
	import org.aswing.border.EmptyBorder;
	import org.aswing.colorchooser.*;
	import org.aswing.dnd.*;
	import org.aswing.event.*;
	import org.aswing.ext.*;
	import org.aswing.geom.*;
	import org.aswing.tree.AbstractLayoutCache;
	
	public class FrameBattle extends JFrame
	{
		//members define
		private var panelMessage:JPanel;
		private var txtMessage:JTextField;
		private var panelSkills:JPanel;
		private var panel_skill_0:PaneBattleSkill;
		private var panel_skill_1:PaneBattleSkill;
		private var panel_skill_2:PaneBattleSkill;
		private var panel_skill_3:PaneBattleSkill;
		private var panel_skill_4:PaneBattleSkill;
		private var panel_skill_5:PaneBattleSkill;
		private var panel_skill_6:PaneBattleSkill;
		private var panel_skill_7:PaneBattleSkill;
		private var panel_skill_8:PaneBattleSkill;
		
		
		private var _skills:Array = new Array();
		//private var _tooltips:Array = new Array;
		public function FrameBattle()
		{
			setClosable(false);
			setResizable(false);  
			setTitleBar(null);
			//getTitleBar().setMinimizeHeight(0);
			setBorder(new EmptyBorder());
			this.setBackgroundDecorator(new SolidBackground(new ASColor(0,0)));
			this.setClipMasked(false);
			this.getContentPane().setClipMasked(false);
			
			//component creation
			setSize(new IntDimension(504, 100));
			setPreferredSize(new IntDimension(504, 100));
			var layout0:SoftBoxLayout = new SoftBoxLayout();
			layout0.setAxis(AsWingConstants.VERTICAL);
			layout0.setAlign(AsWingConstants.CENTER);
			layout0.setGap(0);
			getContentPane().setLayout(layout0);
			
			panelMessage = new JPanel();
			panelMessage.setLocation(new IntPoint(0, 0));
			panelMessage.setSize(new IntDimension(504, 23));
			panelMessage.setPreferredSize(new IntDimension(504, 23));
			var layout1:CenterLayout = new CenterLayout();
			panelMessage.setLayout(layout1);
			
			txtMessage = new JTextField();
			txtMessage.setLocation(new IntPoint(218, 0));
			txtMessage.setSize(new IntDimension(12, 21));
			
			panelSkills = new JPanel();
			panelSkills.setLocation(new IntPoint(0, 0));
			panelSkills.setSize(new IntDimension(504, 77));
			panelSkills.setPreferredSize(new IntDimension(504, 77));
			var layout2:FlowWrapLayout = new FlowWrapLayout();
			layout2.setPreferWidth(200);
			layout2.setAlignment(AsWingConstants.CENTER);
			layout2.setHgap(0);
			layout2.setVgap(0);
			layout2.setMargin(false);
			panelSkills.setLayout(layout2);
			
			panel_skill_0 = new PaneBattleSkill();
			panel_skill_0.setLocation(new IntPoint(0, 2));
			panel_skill_0.setSize(new IntDimension(56, 77));
			panel_skill_0.setPreferredSize(new IntDimension(56, 77));
			
			panel_skill_1 = new PaneBattleSkill();
			panel_skill_1.setLocation(new IntPoint(56, 2));
			panel_skill_1.setSize(new IntDimension(56, 77));
			panel_skill_1.setPreferredSize(new IntDimension(56, 77));
			
			panel_skill_2 = new PaneBattleSkill();
			panel_skill_2.setLocation(new IntPoint(112, 2));
			panel_skill_2.setSize(new IntDimension(56, 77));
			panel_skill_2.setPreferredSize(new IntDimension(56, 77));
			
			panel_skill_3 = new PaneBattleSkill();
			panel_skill_3.setLocation(new IntPoint(168, 2));
			panel_skill_3.setSize(new IntDimension(56, 77));
			panel_skill_3.setPreferredSize(new IntDimension(56, 77));
			
			panel_skill_4 = new PaneBattleSkill();
			panel_skill_4.setLocation(new IntPoint(224, 2));
			panel_skill_4.setSize(new IntDimension(56, 77));
			panel_skill_4.setPreferredSize(new IntDimension(56, 77));
			
			panel_skill_5 = new PaneBattleSkill();
			panel_skill_5.setLocation(new IntPoint(280, 2));
			panel_skill_5.setSize(new IntDimension(56, 77));
			panel_skill_5.setPreferredSize(new IntDimension(56, 77));
			
			panel_skill_6 = new PaneBattleSkill();
			panel_skill_6.setLocation(new IntPoint(336, 2));
			panel_skill_6.setSize(new IntDimension(56, 77));
			panel_skill_6.setPreferredSize(new IntDimension(56, 77));
			
			panel_skill_7 = new PaneBattleSkill();
			panel_skill_7.setLocation(new IntPoint(392, 0));
			panel_skill_7.setSize(new IntDimension(56, 77));
			panel_skill_7.setPreferredSize(new IntDimension(56, 77));
			
			panel_skill_8 = new PaneBattleSkill();
			panel_skill_8.setLocation(new IntPoint(392, 0));
			panel_skill_8.setSize(new IntDimension(56, 77));
			panel_skill_8.setPreferredSize(new IntDimension(56, 77));
			
			
			//component layoution
			getContentPane().append(panelMessage);
			getContentPane().append(panelSkills);
			
			panelMessage.append(txtMessage);
			
			//panelSkills.append(panel_skill_0);
			//panelSkills.append(panel_skill_1);
			//panelSkills.append(panel_skill_2);
			//panelSkills.append(panel_skill_3);
			//panelSkills.append(panel_skill_4);
			//panelSkills.append(panel_skill_5);
			//panelSkills.append(panel_skill_6);
			//panelSkills.append(panel_skill_7);
			//-------------------------
			
			_skills.push(panel_skill_0);
			_skills.push(panel_skill_1);
			_skills.push(panel_skill_2);
			_skills.push(panel_skill_3);
			_skills.push(panel_skill_4);
			_skills.push(panel_skill_5);
			_skills.push(panel_skill_6);
			_skills.push(panel_skill_7);
			_skills.push(panel_skill_8);

			var nIndex:uint = 0;
			for each (var panel:PaneBattleSkill in _skills)
			{
				panel.panelSkill.addEventListener(ClickCountEvent.CLICK_COUNT, onSkillClickCount);  
				panel.setBorder(new EmptyBorder());
				panel.panelSkill.index = nIndex++;
				panel.btn_select_skill.addActionListener(onBtnSelectSkill);
				
			}
			setClipMasked(false);
			getContentPane().setClipMasked(false);
			panelSkills.setClipMasked(false);
			setData();
			var filter:GlowFilter;
			var font:ASFont = new ASFont("宋体", 14, true, false, false, false);
			filter = new GlowFilter(0x000000, 1, 2, 2, 10);
			txtMessage.setFont(font);
			txtMessage.setForeground(ASColor.WHITE);
			txtMessage.filters = new Array(filter);
			txtMessage.setEditable(false);
			txtMessage.setBackgroundDecorator(null);
			txtMessage.setHtmlText('请设置<font color="#FF0000">'+CharInfo.charName+'</font>的操作!');
			txtMessage.pack();
			panelMessage.pack();
		}
		public function getSkillObject(array:Array,skillId:int):Object
		{
			for each(var item:Object in array)
			{
				if(item.csv_id == skillId)
				{
					return item;
				}
			}
			return null;
		}
		public function setData():void
		{
			if(_autoIndex != -1 && panelSkills.contains(_skills[_autoIndex]))
				panelSkills.remove(_skills[_autoIndex]);
			
			for each (var panel:PaneBattleSkill in _skills)
			{
				if(panelSkills.contains(panel))
					panelSkills.remove(panel);
			}
			
			var nIndex:uint = 0;
			for each(var item:Object in CharInfo.m_arSkills)
			{
				_skills[nIndex].item = item;
				if(item.csv_id != 0)
				{
					panelSkills.append(_skills[nIndex]);
					var objSkillCSV:Object = Client.getInstance().GetSkillCSV(item.csv_id);
					if(objSkillCSV != null)
					{
						(_skills[nIndex] as PaneBattleSkill).btn_select_skill.setVisible(false);
					}
				}
				nIndex++;
				if(nIndex >= 5)
					break;
			}
			
			for(var i:int = 0; i < Const.DEFAULT_SKILL_SIZE; i++)
			{
				_skills[nIndex].item = getSkillObject(CharInfo.m_arSkills,CharInfo.m_arDefaultSkills[i]);
				panelSkills.append(_skills[nIndex]);
				(_skills[nIndex] as PaneBattleSkill).btn_select_skill.setVisible(true);
				(_skills[nIndex] as PaneBattleSkill).setSelectSkillState(false);
				nIndex++;
			}
			
			_autoIndex = nIndex;
			panelSkills.append(_skills[nIndex]);
			(_skills[nIndex] as PaneBattleSkill).btn_select_skill.setVisible(false);
			
			_skills[nIndex].item = {csv_id:51,m_nLevel:1,m_nTargetCount:0,m_nRoundCount:0,m_nSuccessRate:0,m_nConsumeHPRate:0}
			pack();
			setLocationXY((Engine.W - width)/2,442);
			FrameBattleSelectSkill.hide();

		}
		
		private var _autoIndex:int = -1;
		private function onSkillClickCount(event:ClickCountEvent):void
		{ 
			var target:PanelSkill = event.target as PanelSkill;
			if(event.getCount() >= 1)
			{   
				if(target.index == _autoIndex)
				{
					FrameBattleAuto.updateBattleAuto();
					return;
				}
				if(!target.battleEnableUse)
					return;
				Client.getInstance().sendPacketLogic(304,[SceneBattle.teamSelf,SceneBattle.indexSelf,target.item.csv_id,_teamTarget,_indexTarget]);
				FrameBattle.hide();
				FrameBattlePartner.show();
			}   	
		}
		private function onBtnSelectSkill(event:Event):void
		{
			var target:JButton = event.target as JButton;
			var panelSkill:PaneBattleSkill = target.parent as PaneBattleSkill;
			if(panelSkill == null)
				return;
			//FrameBattleSelectSkill.show(panelSkill,onSelectSkill);
			if(PaneBattleSkill.clickPanelSkill != null && PaneBattleSkill.clickPanelSkill != panelSkill)
			{
				PaneBattleSkill.clickPanelSkill.setSelectSkillState(false);
				PaneBattleSkill.clickPanelSkill = null;
			}
			panelSkill.setSelectSkillState(!panelSkill.stateDown);
			if(!panelSkill.stateDown && FrameBattleSelectSkill.isShowing())
			{
				FrameBattleSelectSkill.hide();
				return;
			}
			var objSkillCSVSelect:Object = Client.getInstance().GetSkillCSV(panelSkill.panelSkill.item.csv_id);

			var _selectArray:Array = new Array;
			for each(var item:Object in CharInfo.m_arSkills)
			{
				var objSkillCSV:Object = Client.getInstance().GetSkillCSV(item.csv_id);
				if(objSkillCSV != null && objSkillCSV.type == objSkillCSVSelect.type)
				{
					_selectArray.push(item);
				}
			}
			
			PaneBattleSkill.clickPanelSkill = panelSkill;
			FrameBattleSelectSkill._selectType = objSkillCSVSelect.type;
			FrameBattleSelectSkill.show(_selectArray,panelSkill,
				function(panelSkill:PaneBattleSkill):void
				{
					panelSkill.setSelectSkillState(!panelSkill.stateDown);
					var csv_id:int = FrameBattleSelectSkill._selectArray[FrameBattleSelectSkill._selectIndex].csv_id;
					//trace('onBtnSelectSkill:'+panelSkill);
					if(FrameBattleSelectSkill._selectType >= 6 && FrameBattleSelectSkill._selectType <= 8)
					{
						CharInfo.m_arDefaultSkills[Const.DEFAULT_SKILL_CONTROL] = csv_id;
					}
					if(FrameBattleSelectSkill._selectType >= 9 && FrameBattleSelectSkill._selectType <= 11)
					{
						CharInfo.m_arDefaultSkills[Const.DEFAULT_SKILL_ATTACK] = csv_id;
					}
					if(FrameBattleSelectSkill._selectType >= 12 && FrameBattleSelectSkill._selectType <= 14)
					{
						CharInfo.m_arDefaultSkills[Const.DEFAULT_SKILL_ASSIST] = csv_id;
					}
					_needUpdateDefault = true;
					
					Client.getInstance().sendPacketLogic(304,[SceneBattle.teamSelf,SceneBattle.indexSelf,csv_id,_teamTarget,_indexTarget]);
					setData();
					FrameBattle.hide();
					FrameBattlePartner.show();
				},[panelSkill]);
		}
		
		public static function sendDefaultSkills():void
		{
			if(!_needUpdateDefault)
				return;
			Client.getInstance().sendPacketLogic(23,[int(0),CharInfo.m_arDefaultSkills[Const.DEFAULT_SKILL_CONTROL],CharInfo.m_arDefaultSkills[Const.DEFAULT_SKILL_ATTACK],CharInfo.m_arDefaultSkills[Const.DEFAULT_SKILL_ASSIST]]);
			_needUpdateDefault = false;
		}
		
		private static var _needUpdateDefault:Boolean = false;
		private static var _teamTarget:int = -1;
		private static var _indexTarget:int = -1;
		public static function setSkillTarget(team:int,index:int):void
		{
			_teamTarget = team;
			_indexTarget = index;
			FrameBattlePartner.setSkillTarget(team,index);
		}
		
		public static var _frame:FrameBattle = null;
		public static function show():void
		{
			if(SceneBattle.bWatchingBattle)
			{
				FrameBattleWatch.show();
				FrameBattle.hide();
				FrameBattleAuto.hide();
				return;
			}
			FrameBattleWatch.hide();
			if(_frame == null)
			{
				_frame = new FrameBattle();
				PanelMainHelp.getInstance().addChild(_frame);
			}
			_frame.show();
			PanelMainHelp.getInstance().bringToTop(_frame);
			_frame.setData();
			if(FrameBattlePartner.isShowing())
				FrameBattlePartner.hide();
			if(FrameBattleSelectSkill.isShowing())
				FrameBattleSelectSkill.hide();
			FrameBattleCountDown.show(20,function():void
			{
				FrameBattleAuto.updateBattleAuto(0);
				trace("onTimeOver");
			},[]);
			
		}
		public static function hide():void
		{
			if(isShowing())
			{
				_frame.hide();
				sendDefaultSkills();
				FrameBattleCountDown.hide();
			}
		}
		public static function isShowing():Boolean
		{
			return(_frame != null&& _frame.isShowing());
		}
		
		public static function showPartner():void
		{
			FrameBattlePartner.show();
		}
		public static function hidePartner():void
		{
			FrameBattlePartner.hide();
		}
	}
}
import com.*;
import com.Engine.*;
import com.Packet.*;
import com.UI.*;

import flash.display.*;
import flash.display.BitmapData;
import flash.events.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.net.*;
import flash.system.*;
import flash.text.*;
import flash.ui.*;
import flash.utils.*;
import flash.utils.ByteArray;
import flash.utils.getQualifiedClassName;

import org.aswing.*;
import org.aswing.border.*;
import org.aswing.border.EmptyBorder;
import org.aswing.colorchooser.*;
import org.aswing.dnd.*;
import org.aswing.event.*;
import org.aswing.ext.*;
import org.aswing.geom.*;
import org.aswing.graphics.*;
import org.aswing.tree.AbstractLayoutCache;

class FrameBattlePartner extends JFrame
{
	//members define
	private var panelMessage:JPanel;
	private var txtMessage:JTextField;
	private var panelSkills:JPanel;
	private var panel_skill_0:PaneBattleSkill;
	private var panel_skill_1:PaneBattleSkill;
	private var panel_skill_2:PaneBattleSkill;
	private var panel_skill_3:PaneBattleSkill;
	private var panel_skill_4:PaneBattleSkill;
	private var panel_skill_5:PaneBattleSkill;
	private var panel_skill_6:PaneBattleSkill;
	private var panel_skill_7:PaneBattleSkill;
	private var panel_skill_8:PaneBattleSkill;
	
	private var _skills:Array = new Array();
	//private var _tooltips:Array = new Array;
	public function FrameBattlePartner()
	{
		setClosable(false);
		setResizable(false);  
		setTitleBar(null);
		//getTitleBar().setMinimizeHeight(0);
		setBorder(new EmptyBorder());
		this.setBackgroundDecorator(new SolidBackground(new ASColor(0,0)));
		this.setClipMasked(false);
		this.getContentPane().setClipMasked(false);
		
		//component creation
		setSize(new IntDimension(504, 100));
		setPreferredSize(new IntDimension(504, 100));
		var layout0:SoftBoxLayout = new SoftBoxLayout();
		layout0.setAxis(AsWingConstants.VERTICAL);
		layout0.setAlign(AsWingConstants.CENTER);
		layout0.setGap(0);
		getContentPane().setLayout(layout0);
		
		panelMessage = new JPanel();
		panelMessage.setLocation(new IntPoint(0, 0));
		panelMessage.setSize(new IntDimension(504, 23));
		panelMessage.setPreferredSize(new IntDimension(504, 23));
		var layout1:CenterLayout = new CenterLayout();
		panelMessage.setLayout(layout1);
		
		txtMessage = new JTextField();
		txtMessage.setLocation(new IntPoint(218, 0));
		txtMessage.setSize(new IntDimension(12, 21));
		
		panelSkills = new JPanel();
		panelSkills.setLocation(new IntPoint(0, 0));
		panelSkills.setSize(new IntDimension(504, 77));
		panelSkills.setPreferredSize(new IntDimension(504, 77));
		var layout2:FlowWrapLayout = new FlowWrapLayout();
		layout2.setPreferWidth(200);
		layout2.setAlignment(AsWingConstants.CENTER);
		layout2.setHgap(0);
		layout2.setVgap(0);
		layout2.setMargin(false);
		panelSkills.setLayout(layout2);
		
		panel_skill_0 = new PaneBattleSkill();
		panel_skill_0.setLocation(new IntPoint(0, 2));
		panel_skill_0.setSize(new IntDimension(56, 77));
		panel_skill_0.setPreferredSize(new IntDimension(56, 77));
		
		panel_skill_1 = new PaneBattleSkill();
		panel_skill_1.setLocation(new IntPoint(56, 2));
		panel_skill_1.setSize(new IntDimension(56, 77));
		panel_skill_1.setPreferredSize(new IntDimension(56, 77));
		
		panel_skill_2 = new PaneBattleSkill();
		panel_skill_2.setLocation(new IntPoint(112, 2));
		panel_skill_2.setSize(new IntDimension(56, 77));
		panel_skill_2.setPreferredSize(new IntDimension(56, 77));
		
		panel_skill_3 = new PaneBattleSkill();
		panel_skill_3.setLocation(new IntPoint(168, 2));
		panel_skill_3.setSize(new IntDimension(56, 77));
		panel_skill_3.setPreferredSize(new IntDimension(56, 77));
		
		panel_skill_4 = new PaneBattleSkill();
		panel_skill_4.setLocation(new IntPoint(224, 2));
		panel_skill_4.setSize(new IntDimension(56, 77));
		panel_skill_4.setPreferredSize(new IntDimension(56, 77));
		
		panel_skill_5 = new PaneBattleSkill();
		panel_skill_5.setLocation(new IntPoint(280, 2));
		panel_skill_5.setSize(new IntDimension(56, 77));
		panel_skill_5.setPreferredSize(new IntDimension(56, 77));
		
		panel_skill_6 = new PaneBattleSkill();
		panel_skill_6.setLocation(new IntPoint(336, 2));
		panel_skill_6.setSize(new IntDimension(56, 77));
		panel_skill_6.setPreferredSize(new IntDimension(56, 77));
		
		panel_skill_7 = new PaneBattleSkill();
		panel_skill_7.setLocation(new IntPoint(392, 0));
		panel_skill_7.setSize(new IntDimension(56, 77));
		panel_skill_7.setPreferredSize(new IntDimension(56, 77));
		
		panel_skill_8 = new PaneBattleSkill();
		panel_skill_8.setLocation(new IntPoint(392, 0));
		panel_skill_8.setSize(new IntDimension(56, 77));
		panel_skill_8.setPreferredSize(new IntDimension(56, 77));
		
		
		//component layoution
		getContentPane().append(panelMessage);
		getContentPane().append(panelSkills);
		
		panelMessage.append(txtMessage);
		
		//panelSkills.append(panel_skill_0);
		//panelSkills.append(panel_skill_1);
		//panelSkills.append(panel_skill_2);
		//panelSkills.append(panel_skill_3);
		//panelSkills.append(panel_skill_4);
		//panelSkills.append(panel_skill_5);
		//panelSkills.append(panel_skill_6);
		//panelSkills.append(panel_skill_7);
		//-------------------------
		
		_skills.push(panel_skill_0);
		_skills.push(panel_skill_1);
		_skills.push(panel_skill_2);
		_skills.push(panel_skill_3);
		_skills.push(panel_skill_4);
		_skills.push(panel_skill_5);
		_skills.push(panel_skill_6);
		_skills.push(panel_skill_7);
		_skills.push(panel_skill_8);

		
		var nIndex:uint = 0;
		for each (var panel:PaneBattleSkill in _skills)
		{
			panel.panelSkill.addEventListener(ClickCountEvent.CLICK_COUNT, onSkillClickCount);  
			
			//panel.addEventListener(MouseEvent.ROLL_OVER, onRollOver);
			//panel.addEventListener(MouseEvent.ROLL_OUT, onRollOut);
			panel.setBorder(new EmptyBorder());
			panel.panelSkill.index = nIndex++;
			panel.btn_select_skill.addActionListener(onBtnSelectSkill);
		}
		setClipMasked(false);
		getContentPane().setClipMasked(false);
		panelSkills.setClipMasked(false);
		setData();
		var filter:GlowFilter;
		var font:ASFont = new ASFont("宋体", 14, true, false, false, false);
		filter = new GlowFilter(0x000000, 1, 2, 2, 10);
		txtMessage.setFont(font);
		txtMessage.setForeground(ASColor.WHITE);
		txtMessage.filters = new Array(filter);
		txtMessage.setEditable(false);
		txtMessage.setBackgroundDecorator(null);
		txtMessage.setHtmlText('请设置<font color="#FF0000">'+CharInfo.charName+'</font>的操作!');
		txtMessage.pack();
		panelMessage.pack();
	}
	
	public function getSkillObject(array:Array,skillId:int):Object
	{
		for each(var item:Object in array)
		{
			if(item.csv_id == skillId)
			{
				return item;
			}
		}
		return null;
	}
	
	public function setData():void
	{
		var nIndex:uint = 0;
		//var array:Array = null;
		var name:String = null;
		
		_arraySkills = null;
		_currentObject = null;
		if(CharInfo.m_nBattlePartnerType == PanelMain.PARTNER_TYPE_LOVER)
		{
			_arraySkills = CharInfo.objLover.m_arSkills;
			_currentObject = CharInfo.objLover;
			name = CharInfo.objLover.m_szCharName;
		}
		if(CharInfo.m_nBattlePartnerType == PanelMain.PARTNER_TYPE_PET)
		{
			if(CharInfo.m_nPetJoinBattleIndex >= 0 && CharInfo.m_nPetJoinBattleIndex < CharInfo.m_arPets.length)
			{
				_arraySkills = CharInfo.m_arPets[CharInfo.m_nPetJoinBattleIndex].m_arSkills;
				_currentObject = CharInfo.m_arPets[CharInfo.m_nPetJoinBattleIndex];
				name = CharInfo.m_arPets[CharInfo.m_nPetJoinBattleIndex].name;
			}
		}
		
		if(CharInfo.m_nBattlePartnerType == PanelMain.PARTNER_TYPE_SLAVE)
		{
			if(CharInfo.m_nSlaveJoinBattleIndex >= 0 && CharInfo.m_nSlaveJoinBattleIndex < CharInfo.m_arSlaves.length)
			{
				_arraySkills = CharInfo.m_arSlaves[CharInfo.m_nSlaveJoinBattleIndex].m_arSkills;
				_currentObject = CharInfo.m_arSlaves[CharInfo.m_nSlaveJoinBattleIndex];
				name = CharInfo.m_arSlaves[CharInfo.m_nSlaveJoinBattleIndex].m_szCharName;
			}
		}
		if(_arraySkills == null || _currentObject == null)
		{
			FrameBattlePartner.hide();
			//FrameBattleCountDown.hide();
			return;
		}
		txtMessage.setHtmlText('请设置<font color="#FF0000">'+name+'</font>的操作!');
		txtMessage.pack();
		panelMessage.pack();
		
		for each (var panel:PaneBattleSkill in _skills)
		{
			if(panelSkills.contains(panel))
				panelSkills.remove(panel);
		}
		
		if(_arraySkills != null)
		{
			nIndex = 0;
			for each(var item:Object in _arraySkills)
			{
				_skills[nIndex].item = item;
				if(item.csv_id != 0)
					panelSkills.append(_skills[nIndex]);
				var objSkillCSV:Object = Client.getInstance().GetSkillCSV(item.csv_id);
				if(objSkillCSV != null)
				{
					(_skills[nIndex] as PaneBattleSkill).btn_select_skill.setVisible(false);
					(_skills[nIndex] as PaneBattleSkill).setSelectSkillState(false);
				}
				nIndex++;
				if(nIndex >= 4)
					break;
			}
		}
		
		if(_currentObject.m_arDefaultSkills != null)
		{
			for(var i:int = 0; i < Const.DEFAULT_SKILL_SIZE; i++)
			{
				_skills[nIndex].item = getSkillObject(_arraySkills,_currentObject.m_arDefaultSkills[i]);
				trace("_currentObject.m_arDefaultSkills:"+_currentObject.m_arDefaultSkills);
				panelSkills.append(_skills[nIndex]);
				(_skills[nIndex] as PaneBattleSkill).btn_select_skill.setVisible(true);
				nIndex++;
			}
		}
		
		this.revalidate();
		pack();
		setLocationXY((Engine.W - width)/2,442);
		FrameBattleSelectSkill.hide();
	}

	/*private var filterArray:Array = new Array(new GlowFilter(0xFFFF00, 1, 2, 2, 100));
	private function onRollOver(event:MouseEvent):void
	{
		var target:PaneBattleSkill = event.target as PaneBattleSkill;
		if(target == null)
			return;
		panelSkills.bringToTop(target);
		
		if(event.target.filters != filterArray)
			event.target.filters = filterArray;
	}
	
	private function onRollOut(event:MouseEvent):void
	{
		event.target.filters = null;
	}*/
	
	/*private function updateIcon(panel:PanelSkill):void
	{ 
		if(panel.icon_id <= 0)
		{
			panel.setBackgroundDecorator(null);
			return;
		}
		panel.setBackgroundDecorator(new AssetBackground(Client.getSkillElement("img_skill_"+panel.icon_id+"b") as DisplayObject));
	}*/
	static private var _arraySkills:Array = null;
	static private var _currentObject:Object = null;
	private function onSkillClickCount(event:ClickCountEvent):void
	{   
		var target:PanelSkill = event.target as PanelSkill;
		if(event.getCount() >= 1)
		{  
			if(!target.battleEnableUse)
				return;
			if(_arraySkills != null && target.item != null)
				Client.getInstance().sendPacketLogic(304,[SceneBattle.teamSelfPartner,SceneBattle.indexSelfPartner,target.item.csv_id,_teamTarget,_indexTarget]);
			FrameBattlePartner.hide();
		}   	
	} 
	
	private function onBtnSelectSkill(event:Event):void
	{
		var target:JButton = event.target as JButton;
		var panelSkill:PaneBattleSkill = target.parent as PaneBattleSkill;
		if(panelSkill == null)
			return;
		//FrameBattleSelectSkill.show(panelSkill,onSelectSkill);
		if(PaneBattleSkill.clickPanelSkill != null && PaneBattleSkill.clickPanelSkill != panelSkill)
		{
			PaneBattleSkill.clickPanelSkill.setSelectSkillState(false);
			PaneBattleSkill.clickPanelSkill = null;
		}
		panelSkill.setSelectSkillState(!panelSkill.stateDown);
		if(!panelSkill.stateDown && FrameBattleSelectSkill.isShowing())
		{
			FrameBattleSelectSkill.hide();
			return;
		}
		
		if(panelSkill.panelSkill.item == null)
			return;
		var objSkillCSVSelect:Object = Client.getInstance().GetSkillCSV(panelSkill.panelSkill.item.csv_id);
		
		var _selectArray:Array = new Array;
		for each(var item:Object in _arraySkills)
		{
			var objSkillCSV:Object = Client.getInstance().GetSkillCSV(item.csv_id);
			if(objSkillCSV != null && objSkillCSV.type == objSkillCSVSelect.type)
			{
				_selectArray.push(item);
			}
		}
		
		PaneBattleSkill.clickPanelSkill = panelSkill;
		FrameBattleSelectSkill._selectType = objSkillCSVSelect.type;
		FrameBattleSelectSkill.show(_selectArray,panelSkill,
			function(panelSkill:PaneBattleSkill):void
			{
				panelSkill.setSelectSkillState(!panelSkill.stateDown);
				var csv_id:int = FrameBattleSelectSkill._selectArray[FrameBattleSelectSkill._selectIndex].csv_id;
				//trace('onBtnSelectSkill:'+panelSkill);
				if(FrameBattleSelectSkill._selectType >= 6 && FrameBattleSelectSkill._selectType <= 8)
				{
					_currentObject.m_arDefaultSkills[Const.DEFAULT_SKILL_CONTROL] = csv_id;
				}
				if(FrameBattleSelectSkill._selectType >= 9 && FrameBattleSelectSkill._selectType <= 11)
				{
					_currentObject.m_arDefaultSkills[Const.DEFAULT_SKILL_ATTACK] = csv_id;
				}
				if(FrameBattleSelectSkill._selectType >= 12 && FrameBattleSelectSkill._selectType <= 14)
				{
					_currentObject.m_arDefaultSkills[Const.DEFAULT_SKILL_ASSIST] = csv_id;
				}
				_needUpdateDefault = true;
				if(_arraySkills != null)
					Client.getInstance().sendPacketLogic(304,[SceneBattle.teamSelfPartner,SceneBattle.indexSelfPartner,csv_id,_teamTarget,_indexTarget]);
				setData();
				FrameBattlePartner.hide();
			},[panelSkill]);
	}
	public static function sendDefaultSkills():void
	{
		if(!_needUpdateDefault)
			return;
		if(CharInfo.m_nBattlePartnerType == PanelMain.PARTNER_TYPE_SLAVE)
			Client.getInstance().sendPacketLogic(23,[int(1),CharInfo.m_nBattlePartnerType,CharInfo.m_nSlaveJoinBattleIndex,_currentObject.m_arDefaultSkills[Const.DEFAULT_SKILL_CONTROL],_currentObject.m_arDefaultSkills[Const.DEFAULT_SKILL_ATTACK],_currentObject.m_arDefaultSkills[Const.DEFAULT_SKILL_ASSIST]]);
		if(CharInfo.m_nBattlePartnerType == PanelMain.PARTNER_TYPE_LOVER)
			Client.getInstance().sendPacketLogic(23,[int(1),CharInfo.m_nBattlePartnerType,int(0),_currentObject.m_arDefaultSkills[Const.DEFAULT_SKILL_CONTROL],_currentObject.m_arDefaultSkills[Const.DEFAULT_SKILL_ATTACK],_currentObject.m_arDefaultSkills[Const.DEFAULT_SKILL_ASSIST]]);
		_needUpdateDefault = false;
	}
	
	private static var _needUpdateDefault:Boolean = false;
	private static var _teamTarget:int = -1;
	private static var _indexTarget:int = -1;
	public static function setSkillTarget(team:int,index:int):void
	{
		_teamTarget = team;
		_indexTarget = index;
	}
	
	public static var _frame:FrameBattlePartner = null;
	public static function show():void
	{
		if(_frame == null)
		{
			_frame = new FrameBattlePartner();
			PanelMainHelp.getInstance().addChild(_frame);
		}
		_frame.show();
		PanelMainHelp.getInstance().bringToTop(_frame);
		FrameBattleCountDown.show(20,function():void
		{
			FrameBattleAuto.updateBattleAuto(0);
		});
		_frame.setData();
		
	}
	public static function hide():void
	{
		if(isShowing())
		{
			_frame.hide();
			sendDefaultSkills();
			FrameBattleCountDown.hide();
		}
	}
	public static function isShowing():Boolean
	{
		return(_frame != null&& _frame.isShowing());
	}
}

/**
 * MyPaneBattleSkill
 */
class PaneBattleSkill extends JPanel{
	
	//members define
	public var btn_select_skill:JButton;
	public var panelSkill:PanelSkill;
	private var labelSkillName:JLabel;
	
	/**
	 * MyPaneBattleSkill Constructor
	 */
	public function PaneBattleSkill(){
		//component creation
		setLocation(new IntPoint(0, 0));
		setSize(new IntDimension(56, 77));
		setPreferredSize(new IntDimension(56, 77));
		var layout0:EmptyLayout = new EmptyLayout();
		setLayout(layout0);
		
		btn_select_skill = new JButton();
		btn_select_skill.setLocation(new IntPoint(6, 0));
		btn_select_skill.setSize(new IntDimension(44, 11));
		btn_select_skill.setPreferredSize(new IntDimension(44, 11));
		
		panelSkill = new PanelSkill();
		panelSkill.setLocation(new IntPoint(7, 15));
		panelSkill.setSize(new IntDimension(42, 42));
		panelSkill.setPreferredSize(new IntDimension(42, 42));
		
		labelSkillName = new JLabel();
		labelSkillName.setFont(new ASFont("Tahoma", 12, false, false, false, false));
		labelSkillName.setLocation(new IntPoint(2, 59));
		labelSkillName.setSize(new IntDimension(52, 16));
		labelSkillName.setPreferredSize(new IntDimension(52, 16));
		labelSkillName.setText("自动");
		
		//component layoution
		append(btn_select_skill);
		append(panelSkill);
		append(labelSkillName);
		
		var filter:GlowFilter;
		var font:ASFont = new ASFont("宋体", 12, false, false, false, false);
		filter = new GlowFilter(0x000000, 1, 2, 2, 10);
		labelSkillName.setFont(font);
		labelSkillName.setForeground(ASColor.WHITE);
		labelSkillName.setTextFilters(new Array(filter));
		this.setBackgroundDecorator(new AssetBackground(Client.getUIElement("img_battle_skill_bg") as DisplayObject));
		setClipMasked(false);
		btn_select_skill.setClipMasked(false);
		btn_select_skill_up = Client.getUIElement("btn_select_skill_up") as SimpleButton;
		btn_select_skill_down = Client.getUIElement("btn_select_skill_down") as SimpleButton;
		
		btn_select_skill.wrapSimpleButton(btn_select_skill_up);
		btn_select_skill.setText("");
		panelSkill.checkBattleEnableUse = true;
	}
	private var btn_select_skill_up:SimpleButton = null;
	private var btn_select_skill_down:SimpleButton = null;
	private var _item:Object = null;
	public function set item(val:Object):void
	{
		_item = val;
		panelSkill.item = val;
		
		if(_item == null || _item.icon_id <= 0)
		{
			return;
		}
		
		var objSkillCSV:Object = Client.getInstance().GetSkillCSV(item.csv_id);
		if(objSkillCSV == null)
		{
			return;
		}
		labelSkillName.setText(objSkillCSV.name);
	}
	public function get item():Object
	{
		return _item;
	}
	public var stateDown:Boolean = false;
	static public var clickPanelSkill:PaneBattleSkill = null;
	public function setSelectSkillState(bDown:Boolean):void
	{
		stateDown = bDown;
		btn_select_skill.wrapSimpleButton(bDown?btn_select_skill_down:btn_select_skill_up);
	}
	//_________getters_________
}
/**
 * MyPaneBattleMore
 */
class FrameBattleSelectSkill extends JFrame{
	
	//members define
	private var panelSkills:JPanel;
	private var panel_skill_0:PanelSkill;
	private var panel_skill_1:PanelSkill;
	private var panel_skill_2:PanelSkill;
	private var panel_skill_3:PanelSkill;
	private var panel_skill_4:PanelSkill;
	
	/**
	 * MyPaneBattleMore Constructor
	 */
	private var _skills:Array = new Array();
	public function FrameBattleSelectSkill(){
		
		setClosable(false);
		setResizable(false);  
		setTitleBar(null);
		setBorder(new EmptyBorder());
		this.setBackgroundDecorator(new SolidBackground(new ASColor(0,0)));
		setBorder(new EmptyBorder());
		//this.setClipMasked(false);
		//this.getContentPane().setClipMasked(false);
		
		//component creation
		setSize(new IntDimension(224, 48));
		setPreferredSize(new IntDimension(224, 48));
		var layout0:EmptyLayout = new EmptyLayout();
		getContentPane().setLayout(layout0);
		
		panelSkills = new JPanel();
		panelSkills.setLocation(new IntPoint(2, 2));
		panelSkills.setSize(new IntDimension(220, 44));
		panelSkills.setPreferredSize(new IntDimension(220, 44));
		var layout1:GridLayout = new GridLayout();
		layout1.setRows(1);
		layout1.setColumns(5);
		layout1.setHgap(0);
		layout1.setVgap(0);
		panelSkills.setLayout(layout1);
		
		panel_skill_0 = new PanelSkill();
		panel_skill_0.setSize(new IntDimension(44, 44));
		
		panel_skill_1 = new PanelSkill();
		panel_skill_1.setLocation(new IntPoint(10, 0));
		panel_skill_1.setSize(new IntDimension(44, 44));
		
		panel_skill_2 = new PanelSkill();
		panel_skill_2.setLocation(new IntPoint(20, 0));
		panel_skill_2.setSize(new IntDimension(44, 44));
		
		panel_skill_3 = new PanelSkill();
		panel_skill_3.setLocation(new IntPoint(30, 0));
		panel_skill_3.setSize(new IntDimension(44, 44));
		
		panel_skill_4 = new PanelSkill();
		panel_skill_4.setLocation(new IntPoint(40, 0));
		panel_skill_4.setSize(new IntDimension(44, 44));
		
		//component layoution
		getContentPane().append(panelSkills);
		
		panelSkills.append(panel_skill_0);
		panelSkills.append(panel_skill_1);
		panelSkills.append(panel_skill_2);
		panelSkills.append(panel_skill_3);
		panelSkills.append(panel_skill_4);
		
		_skills.push(panel_skill_0);
		_skills.push(panel_skill_1);
		_skills.push(panel_skill_2);
		_skills.push(panel_skill_3);
		_skills.push(panel_skill_4);
		
		panel_skill_0.checkBattleEnableUse = true;
		panel_skill_1.checkBattleEnableUse = true;
		panel_skill_2.checkBattleEnableUse = true;
		panel_skill_3.checkBattleEnableUse = true;
		panel_skill_4.checkBattleEnableUse = true;
		
		panel_skill_0.addEventListener(ClickCountEvent.CLICK_COUNT, onSkillClickCount0);
		panel_skill_1.addEventListener(ClickCountEvent.CLICK_COUNT, onSkillClickCount1);  
		panel_skill_2.addEventListener(ClickCountEvent.CLICK_COUNT, onSkillClickCount2);  
		panel_skill_3.addEventListener(ClickCountEvent.CLICK_COUNT, onSkillClickCount3);  
		panel_skill_4.addEventListener(ClickCountEvent.CLICK_COUNT, onSkillClickCount4); 

		setBackgroundDecorator(new AssetBackground(Client.getUIElement("img_battle_select_skill_bg") as DisplayObject));
		panelSkills.setClipMasked(false);
		this.setClipMasked(false);
		getContentPane().setClipMasked(false);
	}
	public static var _selectIndex:int = 0;
	private function onSkillClickCount0(event:ClickCountEvent):void
	{ 
		if(!panel_skill_0.battleEnableUse)return;
		if(event.getCount() >= 1)
		{ 
			_selectIndex = 0;
			if(func != null)
			{
				func.apply(null, param);
				func = null;
				param = null;
			}
			FrameBattleSelectSkill.hide();
		}   	
	}
	private function onSkillClickCount1(event:ClickCountEvent):void
	{ 
		if(!panel_skill_1.battleEnableUse)return;
		if(event.getCount() >= 1)
		{ 
			_selectIndex = 1;
			if(func != null)
			{
				func.apply(null, param);
				func = null;
				param = null;
			}
			FrameBattleSelectSkill.hide();
		}   	
	}
	private function onSkillClickCount2(event:ClickCountEvent):void
	{ 
		if(!panel_skill_2.battleEnableUse)return;
		if(event.getCount() >= 1)
		{ 
			_selectIndex = 2;
			if(func != null)
			{
				func.apply(null, param);
				func = null;
				param = null;
			}
			FrameBattleSelectSkill.hide();
		}   	
	}
	private function onSkillClickCount3(event:ClickCountEvent):void
	{ 
		if(!panel_skill_3.battleEnableUse)return;
		if(event.getCount() >= 1)
		{ 
			_selectIndex = 3;
			if(func != null)
			{
				func.apply(null, param);
				func = null;
				param = null;
			}
			FrameBattleSelectSkill.hide();
		}   	
	}
	private function onSkillClickCount4(event:ClickCountEvent):void
	{ 
		if(!panel_skill_4.battleEnableUse)return;
		if(event.getCount() >= 1)
		{ 
			_selectIndex = 4;
			if(func != null)
			{
				func.apply(null, param);
				func = null;
				param = null;
			}
			FrameBattleSelectSkill.hide();
		}   	
	}
	
	public function update(array:Array):void
	{
		for each(var item:PanelSkill in _skills)
		{
			item.item = null;
		}
		var nIndex:int = 0;
		for each(var obj:Object in array)
		{
			_skills[nIndex].item = obj;
			nIndex++;
		}
	}
	
	//_________getters_________
	
	static private var func:Function = null;
	static private var param:Array = null;
	public static var _frame:FrameBattleSelectSkill = null;
	public static var _selectArray:Array = null;
	public static var _selectType:int = 0;
	public static function show(array:Array,p:AWSprite,actionFinishHandler:Function=null,handlerParams:Array = null):void
	{
		if(_frame == null)
		{
			_frame = new FrameBattleSelectSkill();
			//PanelMainHelp.getInstance().addChild(_frame);
		}
		p.addChild(_frame);
		_frame.setLocation(new IntPoint((p.width-FrameBattleSelectSkill._frame.width)/2,-FrameBattleSelectSkill._frame.height));
		_frame.show();
		_selectArray = array;
		_frame.update(array);
		p.bringToTop(_frame);
		func = actionFinishHandler;
		param = handlerParams;
		
	}
	public static function hide():void
	{
		if(isShowing())_frame.hide();
	}
	public static function isShowing():Boolean
	{
		return(_frame != null&& _frame.isShowing());
	}
	
	
	
	
}
class FrameBattleCountDown extends JFrame
{
	//members define
	private var panelNumber0:JPanel;
	private var panelNumber1:JPanel;
	
	public function FrameBattleCountDown()
	{
		setClosable(false);
		setResizable(false);  
		setTitleBar(null);
		setBorder(new EmptyBorder());
		this.setBackgroundDecorator(new SolidBackground(new ASColor(0,0)));
		this.setClipMasked(false);
		this.getContentPane().setClipMasked(false);
		
		//component creation
		setSize(new IntDimension(106, 91));
		setPreferredSize(new IntDimension(106, 91));
		var layout0:EmptyLayout = new EmptyLayout();
		getContentPane().setLayout(layout0);
		
		panelNumber0 = new JPanel();
		panelNumber0.setLocation(new IntPoint(11, 18));
		panelNumber0.setSize(new IntDimension(45, 51));
		panelNumber0.setPreferredSize(new IntDimension(45, 51));
		
		panelNumber1 = new JPanel();
		panelNumber1.setLocation(new IntPoint(42, 18));
		panelNumber1.setSize(new IntDimension(45, 51));
		panelNumber1.setPreferredSize(new IntDimension(45, 51));
		
		//component layoution
		getContentPane().append(panelNumber0);
		getContentPane().append(panelNumber1);
		//------------------------------------------
		for(var i:int = 0; i < 10; i++)
		{
			_numbers0[i] = new AssetBackground(Client.getUIElement("img_count_down_"+i) as DisplayObject);
			_numbers1[i] = new AssetBackground(Client.getUIElement("img_count_down_"+i) as DisplayObject);
		}
		setImages();
	}
	private var _numbers0:Array = new Array;
	private var _numbers1:Array = new Array;
	public function setImages():void
	{
		var img_background:DisplayObject = Client.getUIElement("img_count_down_bg") as DisplayObject
		setBackgroundDecorator(new AssetBackground(img_background));
		setSize(new IntDimension(img_background.width, img_background.height));
		setPreferredSize(new IntDimension(img_background.width, img_background.height));
		setLocationXY((Engine.W - width) / 2,73);
		
		panelNumber0.setBackgroundDecorator(_numbers0[1]);
		panelNumber1.setBackgroundDecorator(_numbers1[8]);
		//addEventListener(FrameEvent.FRAME_CLOSING,onFrameClosing);
	}
	public function update():void
	{
		var number_0:int = _count / 10;
		var number_1:int = _count % 10;
		panelNumber0.setBackgroundDecorator(_numbers0[number_0]);
		panelNumber1.setBackgroundDecorator(_numbers1[number_1]);
	}
	private static var _count:int = 20;
	public static var _timeTaskUpdate:Timer = null;
	private static var _filterArray:Array = new Array(new GlowFilter(0xff0000, 1, 40, 40,2));
	//private static var _filterArrayBig:Array = new Array(new GlowFilter(0xff0000, 1, 40, 40,5,1));
	public static function onTimerUpdateTaskInfo(e:TimerEvent):void
	{
		_count --;
		if(_count < 0)
		{
			_count = 0;
			_timeTaskUpdate.stop();
			if(func != null)
			{
				func.apply(null, param);
				func = null;
				param = null;
			}
			hide();
		}
		if(isShowing())
		{
			_frame.update();
			if(_count <= 10)
			{
				SceneMain.shake(_frame,1,4,10);
				_frame.filters = _filterArray;
				//_frame.filters = ((_frame.filters == _filterArray) ? _filterArrayBig : _filterArray);
				//if(_frame.filters == _filterArray) 
				//	_frame.filters = _filterArrayBig;
				//else
				//	_frame.filters = _filterArray;
			}
		}
	}
	static private var func:Function = null;
	static private var param:Array = null;
	public static var _frame:FrameBattleCountDown = null;
	public static function show(count:uint = 20,finishHandler:Function=null,finishHandlerParams:Array = null):void
	{
		if(_frame == null)
		{
			_frame = new FrameBattleCountDown();
			PanelMainHelp.getInstance().addChild(_frame);
		}
		_count = count;
		PanelMainHelp.getInstance().bringToTop(_frame);
		_frame.update();
		_frame.show();
		func = finishHandler;
		param = finishHandlerParams;
		if(_timeTaskUpdate == null)
		{
			_timeTaskUpdate = new Timer(1000);
			_timeTaskUpdate.addEventListener(TimerEvent.TIMER,onTimerUpdateTaskInfo);
			//_timeTaskUpdate.start();
		}
		_frame.filters = null;
		if(!_timeTaskUpdate.running)
			_timeTaskUpdate.start();
		
	}
	public static function hide():void
	{
		if(isShowing())_frame.hide();
		if(_timeTaskUpdate != null && _timeTaskUpdate.running)
		{
			_timeTaskUpdate.stop();
		}
		func = null;
		param = null;
	}
	public static function isShowing():Boolean
	{
		return(_frame != null&& _frame.isShowing());
	}
}